import sys
#这里我们提供必要的引用。基本控件位于pyqt5.qtwidgets模块中。
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QHBoxLayout, QVBoxLayout
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import QFileInfo
 
class TaskUI(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.setGeometry(300,300,800,600)
        self.setWindowTitle('任务管理器')
        root = QFileInfo(__file__).absolutePath()
        self.setWindowIcon(QIcon(root+'/icons8-16.png'))

        okButton = QPushButton("OK")
        cancelButton = QPushButton("Cancel")
 
        hbox = QHBoxLayout()
        hbox.addStretch(1)
        hbox.addWidget(okButton)
        hbox.addWidget(cancelButton)
 
        vbox = QVBoxLayout()
        vbox.addStretch(1)
        vbox.addLayout(hbox)
        
        self.setLayout(vbox)    

        self.show()

if __name__ == '__main__':
    #创建应用程序和对象
    app = QApplication(sys.argv)
    ex = TaskUI()
    sys.exit(app.exec_()) 